import request from '../request'
import type { 
  LoginParams, 
  LoginResult, 
  UserInfo,
  UpdateProfileParams,
  ChangePasswordParams
} from '@/types/auth'

// 更新个人信息参数类型
interface UpdateUserDTO {
  realName: string
  phone: string
  email: string
  departmentId: number
}

export const userApi = {
  // 登录
  login: (data: LoginParams) => {
    return request<string>({
      url: '/v1/auth/login',
      method: 'post',
      data,
      headers: {
        Authorization: ''
      }
    })
  },

  // 获取用户信息
  getUserInfo: () => {
    return request<UserInfo>({
      url: '/v1/users/current',
      method: 'get'
    })
  },

  // 更新个人信息
  updateCurrentUser: (data: UpdateUserDTO) => {
    return request({
      url: '/v1/users/current',
      method: 'put',
      data
    })
  },

  // 修改密码
  changePassword: (data: ChangePasswordParams) => {
    return request({
      url: '/v1/users/password',
      method: 'put',
      data
    })
  },


} 